package twoThreeAnswer;

import twoThree.BiThree;
import twoThree.BiThreeNode;

import java.util.Scanner;

/**
 * @program: practise
 * @description: 输入数据创建二叉树并且输出中序
 * @author: 兔子
 * @create: 2021-10-30 13:09
 **/

public class Test {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        s = "1 2 3 None None 4 5";
        String[] s1 = s.split(" ");
        String sqBiTree = "";
        for (String s2 : s1) {
            if (s2.equals("None")){
                sqBiTree += "*";
            }else {
                sqBiTree += s2;
            }
        }
        BiTreeNode root= createBiTree(sqBiTree,0);
        BiTreeNode.isRootTraverse(root);
    }

    public static BiTreeNode createBiTree(String sqBiTree,int index) {
        BiTreeNode root = null;
        if (index < sqBiTree.length()) {
            root = new BiTreeNode(sqBiTree.charAt(index));
            root.lchild = createBiTree(sqBiTree,2*index + 1);
            root.rchild = createBiTree(sqBiTree,2*index + 2);
        }
        return root;
    }
}

